#include "CTimer.h"


CTimer::CTimer(void)
{
}


CTimer::~CTimer(void)
{
}

void CTimer::Update(void)
{
	if ( m_timerStopped )
	{
		return;
	}

	// Get the current time
	QueryPerformanceCounter( (LARGE_INTEGER *)&m_currentTime );

	m_timeElapsed = (float)(m_currentTime - m_lastTime) / (float)m_ticksPerSecond;
	m_runningTime += m_timeElapsed;

	// Update FPS
	m_numFrames++;
	if (m_currentTime - m_lastFPSUpdate >= m_FPSUpdateInterval )
	{
		float currentTime = (float)m_currentTime / (float)m_ticksPerSecond;
		float lastTime = (float)m_lastFPSUpdate / (float)m_ticksPerSecond;
		m_fps = (float)m_numFrames / (currentTime - lastTime);

		m_lastFPSUpdate = m_currentTime;
		m_numFrames = 0;
	}
	
	m_lastTime = m_currentTime;



}